package com.itheima.controller;

import com.itheima.domain.Result;
import com.itheima.domain.pojo.LoginInfo;
import com.itheima.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class LoginController {
    @Autowired
    private EmpService empService;

    @PostMapping("/login")
    public Result login(@RequestBody Map<String,Object> map){
        LoginInfo loginInfo =empService.login(map);
        if(loginInfo==null){
            return Result.error("用户名或密码错误");
        }
        return Result.success(loginInfo);
    }
}
